<template>
  <div class="config-item-box">
    <el-text class="item-left" v-if="name">
      {{ name }}：
      <el-space :size="5">
        <slot name="name"></slot>
      </el-space>
    </el-text>
    <div
      class="item-right"
      :style="{
        gridTemplateColumns: alone ? '1fr' : '1fr 1fr',
        ...itemRightStyle,
      }"
    >
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps({
  name: {
    type: String,
    required: false,
  },
  alone: {
    type: Boolean,
    default: false,
    required: false,
  },
  itemRightStyle: {
    type: Object,
    default: () => {},
    required: false,
  },
})
</script>

<style lang="scss" scoped>
.config-item-box {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  .item-left {
    width: 100%;
    text-align: left;
    margin: 0 0 10px 0;
    font-size: 12px;
    font-weight: bold;
  }
  .item-right {
    width: 100%;
    display: grid;
    grid-column-gap: 10px;
    font-size: 12px;
  }
}
</style>
